WITH FD_DICTIONARY_TY_1 AS
  (SELECT ROW_NUMBER() OVER(ORDER BY JD.CODE ASC, T.CODE ASC) RN ,T.*, JD.CODE AS PARENT_CO, JD.NAME AS PARENT_NA
  FROM FD_DICTIONARY_TY T
  LEFT JOIN FD_DICTIONARY_TY JD ON (JD.ID = T.PARENT_ID)
  WHERE 1                                 =1
<#if (CODE!) != ''>
  AND (INSTR (T.CODE, :CODE )             > 0
  OR INSTR (T.NAME, :CODE )               > 0)
</#if>
<#if (VALUE!) != ''>
  AND INSTR (T.VALUE, :VALUE )            > 0
</#if>
<#if (DICTIONARY_CODE!) != ''>
  AND EXISTS
    (SELECT 1
    FROM FD_DICTIONARY ED
    WHERE ED.TYPE_ID                        = T.ID
    AND (INSTR (ED.CODE, :DICTIONARY_CODE ) > 0
    OR INSTR (ED.NAME, :DICTIONARY_CODE )   > 0)
    )
</#if>
  )
SELECT T.*
FROM FD_DICTIONARY_TY_1 T
WHERE T.RN BETWEEN :BEGIN__ROW__NUM AND :END__ROW__NUM